use serde::{Deserialize, Serialize};
use crate::protocol::task::NominalTask;
use crate::protocol::type_schema::TypeSchema;
use super::workflow::NominalWorkflow;

pub type Addr = String;
pub type ServiceId = String;
pub type ServiceDescription = String;
pub fn addr2id(addr: Addr) -> ServiceId {
    addr.replace("/", "-").replace(":", "+")
}
#[derive(Debug, Deserialize)]
pub struct ServiceMetaD {
    pub name: Option<String>,
    pub desc: Option<ServiceDescription>,
    pub category: Option<String>,
}
impl Default for ServiceMetaD {
    fn default() -> Self {
        ServiceMetaD { name: None, desc: None, category: None }
    }
}
// pub type TasksMetaD = Vec<NominalTask>;
#[derive(Debug, Deserialize)]
pub struct TasksMetaD {
    pub tasks: Vec<NominalTask>
}

impl Default for TasksMetaD {
    fn default() -> Self {
        TasksMetaD { tasks: vec![] }
    }
}

// pub type WorkflowMetaD = Vec<NominalWorkflow>;
#[derive(Debug, Deserialize)]
pub struct WorkflowMetaD {
    pub workflows: Vec<NominalWorkflow>
}

impl Default for WorkflowMetaD {
    fn default() -> Self {
        WorkflowMetaD { workflows: vec![] }
    }
}

pub type SessionKey = String;
#[derive(Debug, Serialize, Deserialize)]
pub enum HealthyInfo {
    Healthy,
    Warn(String),
    Fatal(String)
} 
#[derive(Debug, Serialize, Deserialize)]
pub struct MountResponseD {
    pub session_key: SessionKey,
    pub healthy_info: HealthyInfo
}